home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trading on the Edge
/
Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin
/
mac
/
Mac_Files
/
Vendor Demos
/
NeuralWare folder
/
nw2v50
/
usermath.h
< prev
next >
Wrap
Text File
|
1993-08-23
|
60KB
|
1,199 lines
/* $Id$ */
/* $Log$ */
/* 1-18-91 (usermath.h) Header for User-Defined Neuro-Dynamics */
/************************************************************************
* Copyright(C) 1987-1992 NeuralWare Inc *
* Penn Center West, IV-227, Pittsburgh, PA 15276 *
* Telephone: (412) 787-8222 FAX: (412) 787-8220 *
* *
* All rights reserved. No part of this program may be reproduced, *
* stored in a retrieval system, or transmitted, in any form or by any *
* means, electronic, mechanical, photocopying, recording or otherwise *
* without the prior written permission of the copyright owner, *
* NeuralWare, Inc. *
* *
* PROPRIETARY NOTICE *
* *
* This document is the property of NeuralWare, Inc. and contains *
* trade-secrets and other proprietary information. The information *
* herein is reserved as proprietary to NeuralWare, and is not to be *
* published, reproduced, copied, disclosed, used, or reverse *
* engineered without the express written consent of a duly authorized *
* representative of NeuralWare. *
************************************************************************
*/
/************************************************************************/
/* */
/* This header file has already been compiled into the */
/* NeuralWorks Object Library. It should not be modified */
/* in any way */
/* */
/************************************************************************/
#ifndef _USERMATH_
#define _USERMATH_
#include "host.h"
#ifdef PUBLIC_FIELDS
#define SHIELD(a) a
#else
#define SHIELD(a) a
#endif
/* problem - TRANS, TRANS_PHYS are defined in n2host.h */
#ifdef TRANS
#define TRANS_STRUCT 1 /* use Transputer variants on structures */
#endif
#ifdef TRANS_PHYS
#define TRANS_STRUCT 1 /* use Transputer variants on structures */
#endif
/************************************************************************/
/* */
/* Ascii File I/O */
/* */
/************************************************************************/
/* 32 bit IEEE floating point Not-A-Number definition. Note that an actual
NAN must also have a non-trivial significand; i.e. at least one of the
trailing zeroes in NAN_MASK must be non-zero. Note: NDPC compiler
must have bit 22 set for a quiet (non-signalling) NAN */
/*
* VAX works under later IEEE conventions -- the same constants apply.
* also, byte reversal swaps/maps (hex) ints and floats identically, so:
*/
#if 0 && (defined(VAXULT) || defined(VMS))
#define NAN_MASK 0x00007f80
#define NAN_VALUE (NAN_MASK|0x00014000)
#else
#define NAN_MASK 0x7f800000
#define NAN_VALUE (NAN_MASK|0x00400001)
#endif
#define ULREP(x) (*((UL *)&(x)))
#define ISNAN(x) ((ULREP(x)&NAN_MASK)==NAN_MASK)
/* ALL the following characters are field separators. Anything with an
ASCII code less than WHITESPACE is a field separator. A field is
defined as a contiguous set of non-separators delimited by separators.
A record is terminated by a NEWLINE followed by a non-continuation
character */
#define WHITESPACE ((NINT)' ')
#define COMMA ((NINT)',')
#define CONTINUATION ((NINT)'&')
#define COMMENT ((NINT)'!')
/* Number of I/O files allowed open: */
#define NUM_IO_FILES 3
#define IOFX_LRN 0 /* Learn file index */
#define IOFX_RCL 1 /* Recall/Test file index */
#define IOFX_AUX 2 /* Auxiliary file index */
/* Number of access schemes for each file: */
#define NUM_ACC_SCHMS 2
GLOBALREF NINT InitRec[NUM_IO_FILES];
/************************************************************************/
/* */
/* Type Definitions */
/* */
/************************************************************************/
/* use NW std random number generator */
#include "n2rand.h"
IMPORT VOID set_rand ARGLIST((long));
IMPORT SL nrand(); /* "long" random number generator */
#define A(x,y) ((x)&(y)) /* "And" of two items */
typedef TEXT Str16[16];
#ifndef DP_RUN
/* display_msg( ) routine can be used to write ascii strings
to the NeuralWorks message area; use in conjunction with
sprintf( ) to display numeric values. msg_gets() prompts for
a string to be typed in the message area; if a value of 1 is
passed to msg_gets(), it returns immediately after a single
character is typed */
VOID display_msg ARGLIST((XB * )); /* write a message to message window */
XB *msg_gets ARGLIST((NINT)); /* get a string from message window */
#endif /* #ifndef DP_RUN */
/************************************************************************/
/* */
/* User Structure Definitions - these definitions */
/* mirror the internal NeuralWorks structure definitions except */
/* that many of the fields remain private. Attempt to access */
/* these private fields will have an undetermined effect */
/* */
/************************************************************************/
/************************************************************************/
/* */
/* Learning and Recall Schedules */
/* */
/************************************************************************/
#define SC_NCOLS 5 /* # of columns in a schedule */
#define SC_COEFS 10 /* # sched coefficients */
#define SC_TEXT 14 /* Maximum text length */
/* The following structure refers to a single column of a learning
and recall schedule. Strangeness is due to compatibilty issues.
*/
typedef struct { /* User version of LR Schedule column */
SL rstep;
/* Recall coefficients (SC_COEFS in all)*/
#define SC_RCOEFS(cp) ((SREAL *) &((cp)->rtemp))
SREAL rtemp; /* recall temperature */
SREAL fire; /* firing rate */
SREAL iclamp; /* input clamp */
SREAL modf; /* mod factor */
SREAL gain; /* gain */
SREAL rcoef[SC_COEFS-5]; /* remaining Coefs */
SL lcount;
/* Learn coefficients (SC_COEFS in all)*/
#define SC_LCOEFS(cp) ((SREAL *)&((cp)->ltemp))
SREAL ltemp; /* learn temperature */
SREAL lcoef1; /* learning coefficient 1 */
SREAL lcoef2; /* learning coefficient 2 */
SREAL lcoef3; /* learning coefficient 3 */
SREAL lcoef[SC_COEFS-4]; /* remaining Coefs */
} USR_SC_COL;
/* The following structure refers to a complete learning and recall
schedule. When an internal (non-user) neuro-dynamics routine is
called the learn and recall counters are compared to "lcount" and
"rstep" to see which columns of the schedule should be used. The
indices of these columns are stored in the layer fields "l_col_x"
and "r_col_x"; pointers to the actual columns are stored in "l_col_p"
and "r_col_p". These column indices and pointers are also calculated
for user defined neuro-dynamics routines in case the user wishes
to stick to the same conventions as the internal routines.
Alternatively the user can ignore the internal conventions and
instead use any parameter in any column of the current schedule;
a pointer to the entire schedule is stored in the layer field "lrs_p".
For example, the user may want to eschew the conventions in cases where
a paradigm has more recall parameters than a single column can hold;
or in cases where parameters in the same row of a schedule are
interpolated to give smoother behavior.
*/
typedef struct {
Str16 rcntrtxt; /* Recall counter text */
Str16 rcoeftxt[SC_COEFS]; /* Recall coeff text */
Str16 lcntrtxt; /* learn counter text */
Str16 lcoeftxt[SC_COEFS]; /* Learn coeff text */
USR_SC_COL lrs_col[SC_NCOLS]; /* Columns */
} USR_SCHED;
/************************************************************************/
/* */
/* Connection Definitions */
/* */
/************************************************************************/
/* The following structure refers to the storage associated with a
single connection. The items "weight" and "last_dw" hold the values
that can be viewed in the destination processing element dialog box.
The source PE is pointed to in "src_pe". The various bits of "flag"
are set through the NeuralWorks menu system when creating or modifying
connections; most of them correspond to the toggle buttons seen in any
of the Connect Dialog Boxes. "CN_DISABLED" is used to flag a connection
which has been disabled on creation or at a later time. "CN_USER"
is provided as a bit which can be used exclusively within a user routine.
*/
typedef struct { /* User version of connection structure */
UW flag; /* flags for the weight: */
#define CN_VAR 0x0000 /* variable (teachable) weight */
#define CN_FIX 0x0001 /* fixed weight (does not learn) */
#define CN_SET 0x0002 /* "set" weight (interacts with iclamp) */
#define CN_MOD 0x0003 /* "mod" weight (interacts with modf) */
#define CN_WT_MASK 0x0003 /* mask for weight types */
#define CN_ABS 0x0000 /* absolute connection */
#define CN_REL 0x0004 /* relative connection */
#define CN_LOC 0x0008 /* local connection */
#define CN_CN_MASK 0x000c /* mask for connections */
#define CN_DISABLED 0x0020 /* connection is "disabled" */
#define CN_PREDIS 0x0010 /* connection is "pre-disabled" */
#define CN_HIDE 0x8000 /* hide the connection */
#define CN_USER 0x0080 /* user connection bit */
struct _usr_pe *src_pe; /* pointer to source PE */
/* NOTE: all instances of the USR_CONN structure are generated
dynamically. The actual number of weight fields allocated per
connection depends on the the n_wt_flds field in the USR_LYR
structure. Only the first weight field is absolutely guaranteed to
be present. The default number of weight fields is 2 but this can be
over-ridden by either an InstaNet script or by the user when adding
a layer. */
SREAL weights[1]; /* weights */
#define weight weights[0] /* weighting factor */
#define last_dw weights[1] /* last delta weight */
} USR_CONN;
#if defined(RS6) || defined(IBP) || defined(I860) || defined(XTM) || defined(THINK_C) || defined(__STDC__) || defined(EWS) || defined(VAXULT) || defined(VMS) || defined(IRIS)
/* --- Required for ANSI standard compilers --- */
#define UPDWXP(wxp,SzWts) (wxp = (USR_CONN *)((XB *)wxp + SzWts))
#define UPDRCP(wxp,SzWts) (wxp = (RCON *)((XB *)wxp + SzWts))
#else
/* --- Faster code generated for non-standard ANSI compilers --- */
#define UPDWXP(wxp,SzWts) ((XB *)wxp += SzWts)
#define UPDRCP(wxp,SzWts) ((XB *)wxp += SzWts)
#endif
/************************************************************************
The following structure is the header for the table of connections
to a destination PE. Each user defined neuro-dynamics routine is
passed a pointer to the current PE together with its associated
connection header (U_CN_HDR structure). Individual connections can
be accessed through "conn_table". "num_conns" gives the actual
number of connections with the given PE as destination.
*/
#define PENL 9 /* PE Name Length */
#define PENALC (PENL+1) /* Amount to allocate */
typedef struct { /* Connection header */
UW SHIELD(num_alc); /* PRIVATE */
UW num_conns; /* # of actual connections */
VOID *ShWtPE; /* shared weight ref */
char PE_Name[L4A(PENALC)]; /* PRIVATE */
USR_CONN conn_table[1]; /* array of connections */
} USR_CN_HDR;
/* */
/************************************************************************
* *
* Virtual Memory Support *
* *
************************************************************************
*/
#ifdef TRANS
typedef unsigned long WAP; /* transputer mode */
#define WAPX2REAL(x) WAP2Real((x)) /* convert it to real */
#define WAPLOCK(x) TRLockWAP((x)) /* lock a virtual pointer */
#define WAPUNLOCK(x) TRUnLockWAP((x)) /* unlock a virtual pointer */
#define WAPFLUSH(x) WAPFlush((x)) /* flush the buffer back to trans */
#else
#ifdef VIRTUAL
/* in virtual mode, the weight array pointer is an offset. The offset
is converted to a "real" pointer by the WAP2REAL() macro.
*/
typedef unsigned long WAP; /* virtual mode */
#define WAPX2REAL(x) WAP2Real((x)) /* convert it to real */
#define WAPLOCK(x) WAPlock((x)) /* lock a virtual pointer */
#define WAPUNLOCK(x) WAPunlock((x)) /* unlock a virtual pointer */
#define WAPFLUSH(x) /* ignore it */
#else
/* in real mode, the weight array pointer is just that. The offset
does NOT need to be converted, so WAP2REAL() macro just passes it back.
*/
typedef USR_CN_HDR *WAP; /* non-virtual mode */
#define WAPX2REAL(x) (x) /* use it as is */
#define WAPLOCK(x) /* lock becomes nothing */
#define WAPUNLOCK(x) /* unlock becomes nothing */
#define WAPFLUSH(x) /* ignore it */
#endif /* VIRTUAL */
#endif /* TRANS */
#ifdef TRANS_PHYS
#define NEWX(p) (Xnew[WORD(p)]) /* current output */
#define PPTR(p) (Xptr[WORD(p)]) /* point to the PE */
#define CERR(p) (Xerr[WORD(p)]) /* error */
#define LAYX(p) (Xlay[WORD(p)]) /* layer index */
#undef WAPX2REAL /* re-define for NCUBE */
#define WAPX2REAL(p) (p) /* real ptrs on NCUBE side */
#else /* TRANS_PHYS */
#define NEWX(p) ((p)->out_val) /* current ouptut */
#define CERR(p) ((p)->err_val) /* error */
#define PPTR(p) (p) /* point to the pe */
#define LAYX(p) ((p)->io_layerx) /* layer index */
#endif /* TRANS_PHYS */
/************************************************************************/
/* */
/* Processing Element Definitions */
/* */
/************************************************************************/
/* The following structure refers to the storage associated with an
individual processing element ( except for the connection header ).
The SREAL values can all be viewed in the Processing Element/Edit
dialog box in NeuralWorks. PEs belonging to a given layer form a
linked list; "pe_next" points to the next PE in that list. The head
of the linked list for the currently processed layer is pointed to
by (USR_LYR *) ulp->l_ep . The bits of "flag" are set and used
internally by NeuralWorks and should be changed with caution:
*/
/* Some forward references */
typedef struct _usr_pe *USR_PE_p;
typedef struct _usr_lyr *USR_LYR_p;
#define USER_PROTO(a) NINT a ARGLIST((USR_PE_p, USR_CN_HDR *, USR_LYR_p))
typedef struct _usr_pe { /* PE structure */
USR_PE_p pe_next; /* 4 pointer to next pe in chain */
UB SHIELD(io_dummy1); /* 1 Dummy byte (old flags) */
UB SHIELD(io_layerx); /* 1 index into layer table for owner */
UW SHIELD(io_penum); /* 2 number of this PE (w/in layer) */
#ifdef TRANS_PHYS
SL SHIELD(io_ordinal); /* 4 actual ordinal of PE */
#endif
SREAL out_val; /* 4 Output Value */
SREAL sum_val; /* 4 Summation Value */
SREAL trn_val; /* 4 Transformed Value */
SREAL cer_val; /* 4 Cum Error Value */
SREAL err_val; /* 4 Error Value */
SREAL err_fac; /* 4 Error Factor */
SREAL des_val; /* 4 Desired Output Value (cnf mtx) */
WAP SHIELD(io_wtoff); /* 4 offset / pointer to weight array */
UW flag; /* 2 flag word */
#define PE_NOT_LEARNED 0x0001 /* PE has never learned */
#define PE_DISABLED 0x0002 /* PE is disabled !! */
#define PE_DLTD 0x0004 /* pe is deleted (unused) */
#define PE_DSPDISAB 0x0008 /* PE Display disabled */
#define PE_NO_IN_CN 0x0010 /* PE has NO connections to it */
#define PE_NO_OUT_CN 0x0020 /* PE has not connections from it */
#define PE_LASTPE 0x0040 /* Last PE in a chain */
#define PE_ALLVAR 0x0080 /* All connections are variable */
#define PE_VARFIX 0x0100 /* Variable & Fixed weights */
#define PE_LEARN_OFF 0x0200 /* disable learning / competition this PE */
#define PE_VARFIXDIS 0x0400 /* Variable, Fixed, Diabled weights */
#define PE_WTNOINCN 0x0800 /* No input conns to source PEs */
#define PE_NEWLY_LRND 0x1000 /* For competitive learning,
PE has just learned for first time */
#define PE_HIDE 0x8000 /* hide PEs weights */
UW SHIELD(io_dummy2); /* 2 dummy area */
#ifdef C_ON_FLY /* "Compile on the Fly" */
USER_PROTO((*pef_sum)); /* 4 Ptr to run time compiled summation */
USER_PROTO((*pef_backp)); /* 4 Ptr to run time compiled back-prop */
USER_PROTO((*pef_learn)); /* 4 Ptr to run time compiled delta rule */
UW FastFlags; /* 2 in-line code flags */
#define FAST_SUM 0x0001 /* in-line summation function */
#define FAST_BACK 0x0002 /* in-line back-propagation */
#define FAST_LEARN 0x0004 /* in-line learning rule */
#define FAST_WTS 0x0008 /* in-line weights */
UW FastCount; /* # of items per math block */
SREAL *FastWts; /* pointer to weight blocks (1/wt component) */
#endif
} USR_PE;
typedef struct _usr_pe PE;
/************************************************************************/
/* */
/* Layer Definitions */
/* */
/************************************************************************/
/* The following structure refers primarily to a layer of the network; it
can also be used to access global network parameters as viewed in the
network dialog box.
A global pointer (um_net), sometimes refered to as the super-layer,
is set up before any user routine is called; it is provided to access
network parameters. um_net is a pointer to a USR_LYR structure.
The meaning of each field is now described; typically, layer fields
should not be written to from a user routine but should be used for
information only.
um_net:
num_pes: Number of layers in the network
sum_f: Not Currently Used
tran_f: Not Currently Used
output_f: Not Currently Used
learn_f: Not Currently Used
l_col_x: Not Relevant
r_col_x: Not Relevant
lrs_p: Pointer to global network LR Schedule ( Network Edit
Dialog Box )
r_col_p: Not Relevant
l_col_p: Not Relevant
counters: Network Counters as viewed in the Network Edit Dialog Box.
counters[CTR_RECALL]: Current Recall Count ( set by
control strategy )
counters[CTR_LAYER]: Current Layer number (set by
control strategy )
counters[CTR_LEARN]: Current Learn Count (incremented
each time a learn is done)
counters[CTR_AUX1]: Aux 1 parameter - used to define
an Epoch for Cumulative Delta
Rule and for Instruments
counters[CTR_AUX2]: Aux 2 parameter
counters[CTR_AUX3]: Aux 3 parameter
counters[CTR_WRK1] and counters[CTR_WRK2] are not accessible
through the Network Edit Dialog Box but can interact with the
control strategy - see documentation on loadable control
strategies for more on this.
*pe_kcur: Not Currently Used
val_kcur: Not Currently Used
*pe_knext: Not Currently Used
val_knext: Not Currently Used
scale: Private Use
offset: Private Use
low_clamp: Private Use
high_clamp: Private Use
fprime_off: Not Currently Used
low_init: Not Currently Used
high_init: Not Currently Used
When a user-defined function is called, one of its arguments is the
current layer (ulp), a pointer to the USR_LYR structure corresponding
to the current layer.
ulp:
num_pes: Number of PEs in the layer
sum_f: Summation function for layer ( Layer Edit Dialog Box )
tran_f: Transfer function for layer ( Layer Edit Dialog Box )
output_f: Output function for layer ( Layer Edit Dialog Box )
learn_f: Learn function for layer ( Layer Edit Dialog Box )
noise_f: Noise function for layer ( Layer Edit Dialog Box )
l_col_x: Index of current learn column of the layer LR Schedule
r_col_x: Index of current recall column of the layer LR Schedule
lrs_p: Pointer to layer LR Schedule ( Layer Edit Dialog Box )
r_col_p: Pointer to current recall column in layer LR Schedule
l_col_p: Pointer to current learn column in layer LR Schedule
counters:
counters[CTR_RECALL]: RESERVED
counters[CTR_LAYER]: RESERVED
counters[CTR_LEARN]: RESERVED
counters[CTR_AUX1]: RESERVED
counters[CTR_AUX2]: RESERVED
counters[CTR_AUX3]: RESERVED
counters[CTR_WRK1]: Available for user use
counters[CTR_WRK2]: Available for user use
*pe_kcur: Kohonen winner. Can be used in user competitive functions
val_kcur: Value of Kohonen winner
*pe_knext: Next winner. Can be used in user competitive functions
val_knext: Value of next winner
scale: Output multiplier (scale) ( Layer Edit Dialog Box )
offset: Output offset ( Layer Edit Dialog Box )
low_clamp: Output low clamp ( Layer Edit Dialog Box )
high_clamp: Output high clamp ( Layer Edit Dialog Box )
fprime_off: Offset for F' ( Layer Edit Dialog Box )
low_init: Low limit of init range ( Layer Edit Dialog Box )
high_init: high limit of init range ( Layer Edit Dialog Box )
*/
/*
The NW_GRAPHIC structure is used within NeuralWorks to define the
graphical look of the layers and screen. All it's contents should be
considered private and never referred to or changed.
*/
typedef SW COMPONENT;
typedef struct {
SW sg_x; /* signed graphic x-coordinate */
SW sg_y; /* signed graphic y-coordinate */
} SWC;
typedef struct {
UW ug_x; /* unsigned graphic x-coordinate */
UW ug_y; /* unsigned graphic y-coordinate */
} UWC;
typedef long GCOORD; /* graphic coordinate */
typedef COMPONENT SCREEN_COORD; /* graphic coordinate for screen*/
#ifdef I860
GLOBALREF SW *i860swptr;
#define SGX(c) (*(i860swptr = ((SW *)(&(c)))))
#define SGY(c) (*((i860swptr = ((SW *)(&(c))))+1))
#else
#define SGX(c) (((SWC *)(&(c)))->sg_x) /* signed x-coordinate */
#define SGY(c) (((SWC *)(&(c)))->sg_y) /* signed y-coordinate */
#endif
#define UGX(c) (((UWC *)(&(c)))->ug_x) /* unsigned x-coordinate */
#define UGY(c) (((UWC *)(&(c)))->ug_y) /* unsinged y-coordinate */
/* --- Layer Display --- */
#define G_NAM_LEN 10 /* length of layer name */
typedef struct {
GCOORD g_cgp; /* 4 current screen position */
NINT g_cgz[2]; /* 4/8 current screen position as array */
UW g_nrws; /* 2 number of rows */
UW g_cgs; /* 2 current screen spacing */
GCOORD g_nt; /* 4 base coordinate of layer */
GCOORD g_hw; /* 4 base psn for hinton weight diagram */
GCOORD g_ha; /* 4 base coordinate of layer for activation */
GCOORD g_io; /* 4 offset for input terminal (signed) */
GCOORD g_oo; /* 4 offset for output terminal (signed) */
UB g_disp; /* 1 display mode */
#define GD_NETWORK 0 /* display as a network */
#define GD_HINTON 1 /* display as a hinton diagram */
#define GD_TITLE 3 /* title page */
UB g_spacing; /* 1 spacing */
UB g_shape; /* 1 display shape */
#define SH_SQUARE 0 /* square */
#define SH_TRIANGLE 1 /* triangle */
#define SH_CIRCLE 2 /* circle */
XB g_name[L4A(G_NAM_LEN+1)]; /* 11 layer name */
} NW_GRAPHIC; /* 46 total length */
/* --- Layer extensions; these are set up and used at the start of and
during execution of a network */
typedef struct _lyr_ext { /* pointers to functions */
USER_PROTO((*sum));
USER_PROTO((*tran));
USER_PROTO((*output));
USER_PROTO((*learn));
USER_PROTO((*error));
USER_PROTO((*noise));
UW fls_flag; /* flag used by fl_sum */
UL cycle_mask;
UW size_wts; /* size of weight array */
UW iox_flags; /* I/O execution flags */
#define IOX_ERR 0x0001 /* I/O error */
#define IOX_TERM 0x0002 /* Request to terminate I/O */
#define IOX_NOW 0x0004 /* Now Mode */
#define IOX_AUTOT 0x0008 /* Automated Test Mode */
#define IOX_LEARN 0x0010 /* Learn Mode */
#define IOX_RECALL 0x0020 /* Recall Mode */
#define IOX_TEST 0x0040 /* Test Mode */
#define IOX_EXPLN 0x0080 /* Explain Mode */
#define IOX_INTRPT 0x0100 /* Execution interrupted */
#define IOX_REINFSTRT 0x0200 /* Start of reinforcement pass */
#define IOX_REDO 0x0400 /* Redo start of reinforcement pass */
#define IOX_CASCMODE 0x0800 /* Cascade mode learning */
} LYR_EXT;
/************************************************************************
* *
* Layer / Super-Layer Structure *
* *
************************************************************************
NOTE: the "OFF_xxxx" defines are used in the HDIR structures to
define where the following field is with respect to the start of a
layer structure. Thus, it is VERY important that these values are
properly updated if the structure is changed in any way.
*/
#define MAX_LAYERS 50 /* max layers to work with */
typedef VOID *PELP;
typedef struct _usr_lyr { /* layer structure */
USR_LYR_p SHIELD(l_next); /* 4 next layer at this level */
USR_LYR_p SHIELD(l_prev); /* 4 previous layer at this level */
USR_LYR_p SHIELD(l_owner); /* 4 pointer to owner layer */
PELP SHIELD(l_ep); /* 4 element pointer */
UW num_pes; /* 2 # of pe's in the layer or
# of layers in network */
UW n_wt_flds; /* 2 wght fields per connection */
UW SHIELD(l_selfx); /* 2 PRIVATE */
UW flag; /* 2 Layer Flags */
#define LF_NESTEDS 0x0001 /* nested super-layers below this */
#define LF_LEAF 0x0002 /* this is a leaf node(only pe's)*/
#define LF_EORS 0x0004 /* end of recall schedule */
#define LF_UEORS 0x0020 /* user end of recall */
#define LF_EOLS 0x0008 /* end of learn schedule */
#define LF_AUTOASSOC 0x0080 /* autoassociative */
#define LF_SELFCONN 0x0010 /* layer is self-connected */
#define LF_REINFORC 0x0040 /* reinforcement learning */
#define LF_INSTANET 0x0200 /* network created using InstaNet */
#define LF_PRJCTION 0x0400 /* projection network or layer */
#define LF_CASCCORR 0x0800 /* cascade correlation network */
#define LF_FMT2File 0x0100 /* format 2 file */
#define LF_REORG 0x4000 /* net needs to be reorganized */
#define LF_HIDE 0x8000 /* hide layer's weights */
#define LF_FMT3File 0x10000l /* format 3 file (new IO stuff) */
#define LF_FMT4File 0x20000l /* format 4 file (aux wght field) */
#define LF_FMT5File 0x40000l /* format 5 file (load net) */
#define LF_FMT6File 0x80000l /* format 6 file (load net) */
#define LF_FMT7File 0x100000l /* format 7 file (load net) */
UW SHIELD(l_lrnio); /* 2 Learn I/O options flag */
UW SHIELD(l_rclio); /* 2 Recall/Test I/O options flag */
#define LIO_ALPHA 1 /* alpha learn files */
#define LIO_FSEQ LIO_ALPHA /* file sequential */
#define LIO_KEY 2 /* keyboard learn input */
#define LIO_FRAND 3 /* file random */
#define LIO_MASK 0x000f /* option mask */
#define LIO_INP 0x0010 /* include input in result file */
#define LIO_DES 0x0020 /* include desired output */
#define LIO_BINARY 0x0040 /* attempt to use/create binary */
#define LIO_USER 0x0080 /* user defined learn function */
#define LIO_FAF 0x0100 /* Fast Ascii (Load file) */
#define LIO_APPEND 0x0200 /* Append to result file */
#define LIO_HEADER 0x0400 /* Include header in result file */
#define LIO_UIOOBJF 0x0800 /* Objctv. func. is a user func. */
UB SHIELD(l_dummy1); /* 1 PRIVATE */
UB SHIELD(l_cntrlx); /* 1 Cntrl Strat idx (Explorer) */
#define LC_DEFAULT 0 /* default Control Strategy (BP) */
#define LC_ADALINE 1 /* adaline / madaline */
#define LC_PERCEPTRON 2 /* perceptron */
#define LC_BACKPROP 3 /* back-propagation */
#define LC_COUNTERPROP 4 /* counter-propagation */
#define LC_HOPFIELD 5 /* hopfield CAN/BSB/BSB-WH */
#define LC_BAM 6 /* bam */
#define LC_TSP 7 /* Traveling-Saleman Problem */
UB SHIELD(l_style); /* 1 Style Index */
UB sum_f; /* summation function index */
#define LS_SUM 1 /* sum of weighted products */
#define LS_ISUM 2 /* "incremental" weighted sum */
#define LS_MAX 3 /* "max" of weighted prod */
#define LS_MIN 4 /* "min" of weighted prod */
#define LS_MAJ 5 /* "majority" */
#define LS_NORMN 6 /* "norm" of n+1 unit vectors */
#define LS_NORM1 7 /* "norm" of unit vector */
#define LS_PROD 8 /* product of weighted inputs */
#define LS_NORMS 9 /* "norm" to scale factor */
#define LS_NORMP 10 /* "polar" norm */
#define LS_NORMM 11 /* "multiplicative" norm */
#define LS_CITYBLK 12 /* City Block */
#define LS_SPR 13 /* SPR */
#define LS_DNNA 14 /* DNNA summation function */
#define LS_SOM 15 /* Self Organizing Map */
/* 16 is a user summation function */
#define LS_LVQ 17 /* Linear Vector Quantization */
#define LS_CASCADE 18 /* Cascade Correlation */
#define LS_EUCLID 19 /* Euclidean Distance */
#define LS_NORMCP 21 /* Central Projection Norm */
#define LS_FZART 22 /* Fuzzy ART */
#define LS_USER1 0x10 /* User Summation 1 */
#define LS_USER2 0x20 /* User Summation 2 */
#define LS_USER3 0x30 /* User Summation 3 */
#define LS_USER4 0x40 /* User Summation 4 */
#define LS_USER5 0x50 /* User Summation 5 */
#define LS_USER6 0x60 /* User Summation 6 */
#define LS_USER7 0x70 /* User Summation 7 */
#define LS_USER8 0x41 /* User Summation 8 */
#define LS_USER9 0x42 /* User Summation 9 */
#define LS_USERA 0x43 /* User Summation A */
#define LS_USERB 0x44 /* User Summation B */
#define LS_USERC 0x45 /* User Summation C */
#define LS_USERD 0x46 /* User Summation E */
#define LS_USERE 0x47 /* User Summation F */
#define LS_USERF 0x48 /* User Summation G */
#define LS_UMASK 0x70 /* User Summation Mask */
UB tran_f; /* 1 transfer function index */
#define LT_LINEAR 1 /* F(k) = k */
#define LT_PERCEPTRON 2 /* F(k) = 0, k<=0; k, k>0 */
#define LT_BSB 3 /* F(k) = -l,k<-l;+h,k>h;else k*/
#define LT_SIGMOID 4 /* F(k) = 1/(1+e**(-k)) */
#define LT_TANH 5 /* F(k) = 0.5 * ( 1 + tanh(k) ) */
#define LT_SINE 6 /* F(k) = sine(k) */
#define LT_SGN 7 /* F(k) = -1,k<0;+1,k>=0 */
#define LT_SGN0 8 /* F(k) = -1,k<0;0,k=0;+1,k>0 */
#define LT_STEPF 9 /* F(k) = 0,k<=0;1,k>0 */
#define LT_PSI 10 /* F(k) = -1,k<0;old k,k=0;1,k>0*/
#define LT_SPR 11 /* F(k) = SPR */
#define LT_DNNA 12 /* F(k) = DNNA transfer function */
#define LT_DNNA_SGM 13 /* F(k) = DNNA Sigmoid trans. fn*/
#define LT_EXP 14 /* Exponential func. (no deriv) */
#define LT_RADBAS 15 /* Radial Basis */
/* 16 is a user function */
#define LT_PNN 17 /* PNN */
#define LT_BOLTZ 18 /* Boltzmann */
#define LT_GRNN 19 /* General Regression Network */
#define LT_USER1 0x10 /* User Transfer 1 */
#define LT_USER2 0x20 /* User Transfer 2 */
#define LT_USER3 0x30 /* User Transfer 3 */
#define LT_USER4 0x40 /* User Transfer 4 */
#define LT_USER5 0x50 /* User Transfer 5 */
#define LT_USER6 0x60 /* User Transfer 6 */
#define LT_USER7 0x70 /* User Transfer 7 */
#define LT_USER8 0x41 /* User Transfer 8 */
#define LT_USER9 0x42 /* User Transfer 9 */
#define LT_USERA 0x43 /* User Transfer A */
#define LT_USERB 0x44 /* User Transfer B */
#define LT_USERC 0x45 /* User Transfer C */
#define LT_USERD 0x46 /* User Transfer E */
#define LT_USERE 0x47 /* User Transfer F */
#define LT_USERF 0x48 /* User Transfer G */
#define LT_UMASK 0x70 /* User Tran. Function Mask */
UB output_f; /* 1 output (update) function index */
#define LU_ALL 0x00 /* no competition ( direct ) */
#define LU_COMP 0x01 /* competitive one winner */
#define LU_FZART 0x11 /* Fuzzy ARTMap, competitive
+ other stuff */
#define LU_SELECT 0x21 /* Direct Output, but selects
winner for learning. */
#define LU_COMP2 0x02 /* competitive, two winners */
#define LU_ACT 0x80 /* only active PEs compete */
#define LU_COMPACT (LU_COMP|LU_ACT) /* competitive, 1 highest active */
#define LU_COMPACT2 (LU_COMP2|LU_ACT) /* competitive, 2 highest active */
#define LU_ADALINE 0x04 /* adaline competition */
#define LU_SPR 0x08 /* spr competition */
#define LU_DNNA 0x14 /* dnna output - non-competitive */
#define LU_FZARTMAP 0x18 /* ARTMap output layer */
#define LU_LVQ 0x24 /* Linear Vector Quantization */
#define LU_SOM 0x28 /* Self Organizing Map */
#define LU_NORM 0x34 /* Normalized outputs */
#define LU_MODNNGT 0x38 /* Modular NN gating output */
#define LU_DIVIDE 0x54 /* Divide by first PEs */
#define LU_SOFTMAX 0x58 /* SoftMax exp(I)/SUM(exp(I)) */
#define LU_USER1 0x10 /* User Output 1 */
#define LU_USER2 0x20 /* User Output 2 */
#define LU_USER3 0x30 /* User Output 3 */
#define LU_USER4 0x40 /* User Output 4 */
#define LU_USER5 0x50 /* User Output 5 */
#define LU_USER6 0x60 /* User Output 6 */
#define LU_USER7 0x70 /* User Output 7 */
#define LU_USER8 0x41 /* User Output 8 */
#define LU_USER9 0x42 /* User Output 9 */
#define LU_USERA 0x43 /* User Output A */
#define LU_USERB 0x44 /* User Output B */
#define LU_USERC 0x45 /* User Output C */
#define LU_USERD 0x46 /* User Output E */
#define LU_USERE 0x47 /* User Output F */
#define LU_USERF 0x48 /* User Output G */
#define LU_UMASK 0x70 /* User Output Function Mask */
UB learn_f; /* 1 learn function index */
#define LL_NONE 0x00 /* fanout - no learning */
#define LL_HEBB 0x01 /* hebbian */
#define LL_HEBBANTI 0x02 /* hebb / anti-hebbian */
#define LL_HOPFIELD 0x03 /* hopfield */
#define LL_BSB_WH 0x04 /* bsb Widrow-Hoff */
#define LL_BSB_HOPF 0x05 /* bsb hopfield learning */
#define LL_WIDHOFF 0x06 /* widrow-hoff (CPN) */
#define LL_KOHONEN 0x07 /* kohonen learning */
#define LL_KOHONEN1 0x08 /* kohonen - post normalize to 1 */
#define LL_KOHONENN 0x09 /* kohonen - post normalize to n */
#define LL_GDELTA 0x0a /* generalized delta rule */
#define LL_ADALINE 0x0b /* ADALINE learning */
#define LL_PERCEPTRON 0x0c /* perceptron learning */
#define LL_CUMGDELTA 0x0d /* cumulative generalized delta */
#define LL_SPR 0x0e /* SPR learning rule */
#define LL_ART1 0x0f /* ART 1 learning rule */
#define LL_NORMCUMD 0x11 /* Normalized cum delta */
#define LL_EDBD 0x12 /* Extended Delta Bar Delta */
#define LL_DBD 0x13 /* Delta Bar Delta */
#define LL_DRS 0x14 /* Directed Random Search */
#define LL_SOM 0x15 /* Self-Organizing Map */
/* 16 is a user learn function */
#define LL_LVQ 0x17 /* Linear Vector Quantization */
#define LL_GENETIC 0x18 /* Genetic Reinforcement Learning */
#define LL_GRCNTRL 0x19 /* Genetic Reinforcement Control */
#define LL_FZART 0x1a /* Fuzzy ARTMAP */
#define LL_PROJNN 0x1b /* Projective delta rule */
#define LL_KMEANS 0x1c /* Use for Euclidean, City block
or Projective Kohonen learning.
If source layer is projective,
will project to radius of the
hypersphere */
#define LL_PNN 0x1d /* PNN learn function */
#define LL_BOLTZ 0x1e /* Boltzmann */
#define LL_QUICKPROP 0x1f /* Quick Prop */
#define LL_MAXPROP 0x21 /* Max Prop */
#define LL_GRNN 0x22 /* GRNN learn function */
#define LL_USER1 0x10 /* User Learn 1 */
#define LL_USER2 0x20 /* User Learn 2 */
#define LL_USER3 0x30 /* User Learn 3 */
#define LL_USER4 0x40 /* User Learn 4 */
#define LL_USER5 0x50 /* User Learn 5 */
#define LL_USER6 0x60 /* User Learn 6 */
#define LL_USER7 0x70 /* User Learn 7 */
#define LL_USER8 0x41 /* User Learn 8 */
#define LL_USER9 0x42 /* User Learn 9 */
#define LL_USERA 0x43 /* User Learn A */
#define LL_USERB 0x44 /* User Learn B */
#define LL_USERC 0x45 /* User Learn C */
#define LL_USERD 0x46 /* User Learn E */
#define LL_USERE 0x47 /* User Learn F */
#define LL_USERF 0x48 /* User Learn G */
#define LL_UMASK 0x70 /* User Learn Function Mask */
UB error_f; /* 1 error function */
#define LE_STANDARD 0 /* normal error function */
#define LE_QUADRATIC 1 /* quadratic */
#define LE_CUBIC 2 /* cubic */
#define LE_TOLERANT 3 /* tolerant */
#define LE_DRS 4 /* Directed Random Search */
#define LE_MODNNGT 5 /* Modular NN Gating error */
#define LE_KNN 6 /* K Nearest neighbour */
#define LE_SOFTMAX 7 /* Softmax */
#define LE_CASCADE 8 /* Cascade error */
#define LE_USER1 0x10 /* User Error 1 */
#define LE_USER2 0x20 /* User Error 2 */
#define LE_USER3 0x30 /* User Error 3 */
#define LE_USER4 0x40 /* User Error 4 */
#define LE_USER5 0x50 /* User Error 5 */
#define LE_USER6 0x60 /* User Error 6 */
#define LE_USER7 0x70 /* User Error 7 */
#define LE_USER8 0x41 /* User Error 8 */
#define LE_USER9 0x42 /* User Error 9 */
#define LE_USERA 0x43 /* User Error A */
#define LE_USERB 0x44 /* User Error B */
#define LE_USERC 0x45 /* User Error C */
#define LE_USERD 0x46 /* User Error E */
#define LE_USERE 0x47 /* User Error F */
#define LE_USERF 0x48 /* User Error G */
#define LE_UMASK 0x70 /* User Error Function Mask */
UB noise_f; /* 1 Noise function (used for
weigt initialization also */
#define LN_UNIFORM 0
#define LN_GAUSSIAN 1
#define LN_NONE 2
#define LN_USER1 0x10 /* User Noise 1 */
#define LN_USER2 0x20 /* User Noise 2 */
#define LN_USER3 0x30 /* User Noise 3 */
#define LN_USER4 0x40 /* User Noise 4 */
#define LN_USER5 0x50 /* User Noise 5 */
#define LN_USER6 0x60 /* User Noise 6 */
#define LN_USER7 0x70 /* User Noise 7 */
#define LN_USER8 0x41 /* User Noise 8 */
#define LN_USER9 0x42 /* User Noise 9 */
#define LN_USERA 0x43 /* User Noise A */
#define LN_USERB 0x44 /* User Noise B */
#define LN_USERC 0x45 /* User Noise C */
#define LN_USERD 0x46 /* User Noise E */
#define LN_USERE 0x47 /* User Noise F */
#define LN_USERF 0x48 /* User Noise G */
#define LN_UMASK 0x70 /* User Noise Function Mask */
UB SHIELD(l_lrsched); /* 1 Schedule index */
#define LRS_DEFAULT 0 /* default schedule */
UB SHIELD(l_mmtable); /* 1 MinMax table index */
#define MMT_DEFAULT 0
UB l_col_x; /* 1 current lrn column in sched */
UB r_col_x; /* 1 current rcl column in sched */
#ifdef C_ON_FLY
UB l_col_n; /* 1 # of cols in learn sched FC2 */
UB r_col_n; /* 1 # of cols in recall sched FC2 */
#endif
USR_SCHED *lrs_p; /* 1 LR Schedule pointer */
USR_SC_COL *r_col_p; /* 1 current recall column ptr */
USR_SC_COL *l_col_p; /* 1 current learn column ptr */
NW_GRAPHIC SHIELD(l_dsp); /* 46 PRIVATE */
#define N_COUNTERS 8 /* # of counters */
SL counters[N_COUNTERS];/* 32 counter array */
#define CTR_RECALL 0 /* recall cycle */
#define CTR_LAYER 1 /* layer number */
#define CTR_LEARN 2 /* learn count */
#define CTR_AUX1 3 /* aux 1 */
#define CTR_AUX2 4 /* aux 2 */
#define CTR_AUX3 5 /* aux 3 */
#define CTR_WRK1 6 /* work 1 */
#define CTR_WRK2 7 /* work 2 */
/* Kohonen -winner information */
#define l_layer_n counters[CTR_LAYER] /* current layer */
#define l_counter counters[CTR_RECALL] /* counter (recall cycle) */
#define l_epoch counters[CTR_LEARN] /* learning counter */
USR_PE *pe_kcur; /* 4 Current or positive winner */
SREAL val_kcur; /* 4 Value of winner */
USR_PE *pe_knext; /* 4 Next or negative winner */
SREAL val_knext; /* 4 Value of winner */
SREAL scale; /* 4 output multiplier (scale) */
#define l_ip_lo scale /* OR input target range low
for super-layer */
SREAL offset; /* 4 output offset */
#define l_ip_hi offset /* OR input target range high
for super-layer */
SREAL lo_clip; /* 4 output low clip */
#define l_op_lo lo_clip /* OR des. output target range low
for super-layer */
SREAL hi_clip; /* 4 output high clip */
#define l_op_hi hi_clip /* OR des. output target range high
for super-layer */
SREAL fprime_off; /* 4 offset for f' */
SREAL low_init; /* 4 low initialization limit */
SREAL high_init; /* 4 high initialization limit */
SREAL SHIELD(normsum); /* 4 PRIVATE */
NINT SHIELD(l_XecFlags);/* 2/4 PRIVATE */
#ifdef C_ON_FLY
NINT SHIELD(l_XecMathF); /* PRIVATE FC2 */
NINT SHIELD(l_XecWType); /* PRIVATE FC2 - weight types */
#define XEC_WTDISAB 0x0001 /* disabled */
#define XEC_WTVAR 0x0002 /* variable */
#define XEC_WTSET 0x0004 /* set-type */
#define XEC_WTMOD 0x0008 /* mod-type */
#define XEC_WTFIX 0x0010 /* fixed type */
#define XEC_WTNOINC 0x0020 /* inputs have no conns */
#define XEC_PEDIS 0x0040 /* a PE is disabled */
#define XEC_LRNDIS 0x0080 /* learning disabled */
#define XEC_ZCLAMP 0x0100 /* LRS Clamp = 0.0 */
#define XEC_ZLNOISE 0x0200 /* LRS Learn Temp = 0.0 */
#define XEC_ZRNOISE 0x0400 /* LRS Recall Temp = 0.0 */
#define XEC_FIRE100 0x0800 /* LRS Fire = 100.0 ! */
/* NOTE: Uses UMCF_XXX flags */
#endif
#ifndef TRANS_PHYS
char SHIELD(l_uionam)[FNALC]; /* PRIVATE */
char SHIELD(l_uiolrn)[FNALC]; /* PRIVATE */
char SHIELD(l_uiorcl)[FNALC]; /* PRIVATE */
#endif /* TRANS_PHYS */
LYR_EXT functions; /* run-time math pointers and flag */
} USR_LYR;
typedef struct _usr_lyr LAYER;
#define ISUSER(x) ( ((x) & 0x40) || ( (x) && (((x)&0x70) == (x) )) )
/* */
/************************************************************************
* *
* MinMax Tables *
* *
************************************************************************
MinMax tables hold the minimum and maximum values for each column of
IO. These tables are typically created from training, test and/or
master data files throught the MinMax utilities. These utilities
provide for MinMax tables to be merged with other tables and files.
The MinMax utilities should give warnings if an attempt is made to
merge potentially incompatible tables and/or files but it is ultimately
up to the user to ensure valid tables.
The set of values in a MinMax table are synchronised with the columns
in the data file rather than in the network. The link between the
file values and the values presented to the network are determined
by Network IO parameters.
*/
typedef struct {
SREAL mme_min; /* Minimum of range */
SREAL mme_max; /* Maximum of range */
} MMT_ENT;
typedef struct {
SL mm_nent; /* Number of entries */
MMT_ENT mm_ent[1]; /* Table of entries */
} MMT;
#ifndef MAXFLOAT
#define MAXFLOAT (1.0e35) /* maximum float value */
#endif
#define MMT_MIN_INIT MAXFLOAT
#define MMT_MAX_INIT (-MMT_MIN_INIT)
/**/
/************************************************************************/
/* */
/* Control Strategy Math Instruction Microcode Bits */
/* */
/************************************************************************/
/* A control strategy math instruction can be thought of as a microcode
instruction where each operation corresponds to a bit in a microcode
vector. Refer to the documentation on User Defined Control Strategies
for more information on this. The global variable "um_micro" (declared
below and defined in usermath.c) makes the microcode vector available
to the user math routines. Symbols for each bit are defined below; the
corresponding control strategy literal is added as a comment.
*/
#define MF_SETBIT 0x10000000l /* "setb" */
#define MF_SETX 0x00000001l /* "o=0" */
#define MF_SET 0x00001000l /* "set" */
#define MF_FIRE 0x00002000l /* "fire" */
#define MF_SUM 0x00004000l /* "sum" */
#define MF_WEQI 0x00000080l /* "w=i" */
#define MF_IEQER 0x00000100l /* "i=e" */
#define MF_CEEQER 0x00000400l /* "ce=e" */
#define MF_EREQO 0x00000020l /* "e=o" */
#define MF_WEQER 0x00000040l /* "w=e" */
#define MF_EREQCE 0x00000800l /* "e=ce" */
#define MF_LNOISE 0x00008000l /* "lnoise" */
#define MF_RNOISE 0x00010000l /* "rnoise" */
#define MF_TRAN 0x00020000l /* "tran" */
#define MF_OUTPUT 0x00040000l /* "output" */
#define MF_GATE 0x00080000l /* "gate" */
#define MF_ERROR 0x00100000l /* "e-=w" */
#define MF_ERRFAC 0x00000002l /* "e*=ef */
#define MF_REGRESS 0x40000000l /* "regress" */
#define MF_OEQTRN 0x00000008l /* "o=w" */
#define MF_EREQW 0x00200000l /* "e=w" */
#define MF_IEQWX 0x00000200l /* "i=w" */
#define MF_ERFPRM 0x00400000l /* "e*=f'" */
#define MF_COUNTER 0x00800000l /* "cterr" */
#define MF_SWAP 0x00000004l /* "swap" */
#define MF_BACKP 0x01000000l /* "backp" */
#define MF_LEARN 0x02000000l /* "learn" */
#define MF_SETW 0x04000000l /* "w=0" */
#define MF_SETE 0x08000000l /* "e=0" */
#define MF_RESET 0x20000000l /* "reset" */
/* flags used in math routines */
#define FLS_FIRE 0x0001 /* check for firing */
#ifndef C_ON_FLY
#define FLS_NOISE 0x0002 /* noise (l/r) is not zero */
#else
#define FLS_RNOISE 0x0002 /* noise (recall) is not zero */
#define FLS_LNOISE 0x4000 /* noise (learning) in non-zero */
#define FLS_NOISE (FLS_RNOISE|FLS_LNOISE)
#endif
#define FLS_COEF3 0x0004 /* LCOEF3 is not zero */
#define FLS_SCALE 0x0008 /* scale only as part of s/o */
#define FLS_OFFONLY 0x0010 /* offset only as part of scale */
#define FLS_NORMF 0x0020 /* normalizing layer */
#define FLS_USR_LEARN 0x0040 /* user learn function */
#define FLS_USR_SUM 0x0080
#define FLS_USR_OUT 0x0100
#define FLS_USR_TRAN 0x0200
#define FLS_USR_ERROR 0x0400
#define FLS_CKLIMS 0x0800 /* check limits */
#define FLS_BKPNC 0x1000 /* back prop to PEs with NO connections */
#define FLS_FTHRESH 0x2000 /* F' threshold != 0 */
#define FLS_EOE 0x8000 /* End of epoch flag */
#define FLS_ANY_USER (FLS_USR_SUM|FLS_USR_TRAN|FLS_USR_OUT|FLS_USR_LEARN|FLS_USR_ERROR)
/* global math flags */
#ifndef DPK
GLOBALREF UW um_flag; /* user math control flag */
GLOBALREF UL um_micro; /* control strategy math microcode */
#endif
GLOBALREF USR_LYR *um_net; /* pointer to super layer */
GLOBALREF SL *um_ctr; /* counters FC2 */
#define UMCF_PRELYR 0x0001
#define UMCF_POSTLYR 0x0002
#define UMCF_EPOCHEND 0x0004
#define UMCF_INIT 0x0008
#define UMCF_DERIV 0x1000
#define UMCF_LEARN 0x00f0
#define UMCF_RECALL 0x0f00
#define IS_PRELYR (um_flag & UMCF_PRELYR)
#define IS_POSTLYR (um_flag & UMCF_POSTLYR)
#define IS_DERIV (um_flag & UMCF_DERIV)
#define IS_INIT (um_flag & UMCF_INIT)
#define IS_PRE_POST (um_flag & (UMCF_PRELYR|UMCF_POSTLYR))
#define IS_LEARN (um_flag & UMCF_LEARN)
#define IS_EPOCH (um_flag & UMCF_EPOCHEND)
/* PE memory management functions */
NINT PEVecAlc ARGLIST(( NINT ) ); /* allocate PE Vector */
USR_PE *PEX2Ptr ARGLIST(( UW ) ); /* convert a PE # to a pointer */
UW PEPtr2X ARGLIST(( USR_PE * ) ); /* convert a pointer to a PE # */
/* --- Virtual Memory Management --- */
USR_CN_HDR *WAP2Real ARGLIST(( WAP ) ); /* convert a WAP to real */
WAP WAFree ARGLIST(( WAP ) ); /* free a weight array */
WAP WAAlloc ARGLIST(( UW, UW, UW ) ); /* alloc a weight array */
WAP WAReAlloc ARGLIST(( UW, UW, WAP ) ); /* re-alloc a weight array */
VOID WAPlock ARGLIST(( USR_CN_HDR * )); /* lock routine */
VOID WAPunlock ARGLIST(( USR_CN_HDR * )); /* unlock routine */
/* an array of 16 SREAL and 16 UL values which are stored with a network
and retrived when the network is read. You may use these for any
information which must be retained when a net is saved. It is up
to you to avoid any conflicts in usage */
#define MAX_SLOTS 16
#ifndef DP_RUN
GLOBALREF SREAL User_Floats[MAX_SLOTS]; /* array of floats which are
stored with network */
GLOBALREF UL User_Longs[MAX_SLOTS]; /* array of Longs which are
stored with network */
GLOBALREF LAYER **LTable; /* The layer table */
GLOBALREF UW LTCurN; /* current # of used entries */
GLOBALREF USR_PE *PE_vector; /* processing element array */
GLOBALREF UW PE_nvec; /* # of vectors allocated (<=MAX_VEC) */
#else
#define User_Floats (mptr->U_Floats)
#define User_Longs (mptr->U_Longs)
#define LTable (mptr->layers)
#define LTCurN (mptr->num_lay)
#define PE_vector (mptr->peptr)
#define PE_nvec (mptr->alc_pes)
#endif /* ifndef DP_RUN */
GLOBALREF UW PE_nnxt; /* first "free" (maybe) PE (place to start) */
/* layer to index */
#define LP2LX(p) (((p)==(LAYER *)0)? (int)(-1):(p)->l_selfx)
/* convert a layer index to pointer */
#ifdef VMS
#define SIGNED
#else
#define SIGNED signed
#endif
#define LX2LP(x) (((LTable!=(LAYER **)0)&&(0<=(SIGNED char)(x)&&(x)<LTCurN))? LTable[(x)]:(LAYER *)0)
/************************************************************************/
/* */
/* External Definitions */
/* */
/************************************************************************/
/* The following defines are used by um_event() to indicate the kind
of event which is occurring */
#define UME_LSTART 1 /* start learning */
#define UME_LEND 2 /* end learning */
#define UME_RSTART 3 /* start recall */
#define UME_TSTART 4 /* start test */
#define UME_REND 5 /* end recall/test */
#define UME_LOAD 6 /* network just loaded */
#define UME_SAVE 7 /* about to save network */
#define UME_DELETE 8 /* about to delete network */
#define UME_INIT 9 /* network has just been initialized */
/* Prototypes */
NINT setup_umath ARGLIST((void));
NINT um_event ARGLIST((XB *, XB *, USR_LYR *, NINT ));
NINT um_chkpt ARGLIST((USR_PE *, USR_CN_HDR *, USR_LYR * ));
/* Auxilary Routines used in Math Functions */
NINT PEWtNorm ARGLIST(( USR_PE *, NINT, NINT ) ); /* normalize wts in a PE */
/* --- message handling --- */
XB *msg_gets ARGLIST(( NINT ) ); /* get a message from keyboard */
#ifdef MAC
#define PNLEN 255 /* max length for a path */
#else
#define PNLEN 63 /* max length for a path */
#endif
#define find_weights(wap,n,wxp) ((wap!=(USR_CN_HDR *)0)? \
(wxp= &wap->conn_table[0],(n=wap->num_conns)<=0):(wxp=(USR_CONN *)0,n=0,1))
#endif /* ifndef _USERMATH_ */